package com.king.hpeproject.constant;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 响应包的基类
 */
@Data
@NoArgsConstructor
public class BaseResponse<T> {
    private int status;
    private String errCode;
    private String msg;
    private T data;
    private static final String dataKey = "data";
    private static final String success = "success";
    private static final String fail = "failure";

    private BaseResponse(int status, String msg, T data){
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public static <T> BaseResponse<T> ok(){
        return new BaseResponse<>(200, success, null);
    }

    public static <T> BaseResponse<T> error(int status, String msg){
        return new BaseResponse<>(status, msg, null);
    }

}
